home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / generic.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-04  |  2.6 KB  |  91 lines  |  [TEXT/MPS ]

  1. /*
  2.  *------------------------------------------------------------------------
  3.  * Copyright:
  4.  *      © 1993 by Apple Computer Inc.  all rights reserved.
  5.  *
  6.  * Project:
  7.  *      PowerPC C++ Streams Library
  8.  *
  9.  * Filename:
  10.  *      generic.h
  11.  *
  12.  * Created:
  13.  *      (unknown)
  14.  *
  15.  * Modified:
  16.  *      Date     Engineer       Comment
  17.  *      -------- -------------- ------------------------------------------
  18.  *      12/17/93 Rudy Wang      Made this file universal.
  19.  *------------------------------------------------------------------------
  20.  */
  21. #ifndef __GENERICH__
  22. #define __GENERICH__        1
  23.  
  24. /*
  25.  * macros to paste tokens together to form new names
  26.  */
  27.  
  28. #if defined(applec) || defined(powerc)
  29.  
  30. /*
  31.  * ANSI C preprocessors will not expand the arguments to a macro;
  32.  * so we need to add a level of indirection to allow macro expansion of
  33.  * arguments.  (Reiser preprocessors allowed the first arg to be expanded;
  34.  * this method will allow both to be expanded, which is better than none.)
  35.  */
  36. #define name2(a,b)           _name2_aux(a,b)
  37. #define _name2_aux(a,b)      a##b
  38. #define name3(a,b,c)         _name3_aux(a,b,c)
  39. #define _name3_aux(a,b,c)    a##b##c
  40. #define name4(a,b,c,d)       _name4_aux(a,b,c,d)
  41. #define _name4_aux(a,b,c,d)  a##b##c##d
  42.  
  43. #else 
  44.  
  45. #os bsd3 svr2 svr3 sunos3 sunos4 hpux uts
  46. #define name2(a,b)      a/**/b
  47. #define name3(a,b,c)    a/**/b/**/c
  48. #define name4(a,b,c,d)  a/**/b/**/c/**/d
  49. #endos
  50. #os bsd2 alliant
  51. #define name2(a,b) a\
  52. b
  53. #define name3(a,b,c) a\
  54. b\
  55. c
  56. #define name4(a,b,c,d) a\
  57. b\
  58. c\
  59. d
  60. #endos
  61.  
  62. #endif
  63.  
  64. #ifdef applec 
  65.  
  66. // Alas, MPW C++ doesn't have an ANSI C conformant preprocessor, so
  67. //  the AT&T code as given doesn't work. The code below will work for 
  68. //  MPW C++, but **NOT** for a compiler with an ANSI C conformant
  69. //  preprocessor because the preprocessor isn't supposed to expand 
  70. //  operands of ##. Undefine applec to use this header with other
  71. //  compilers. Thanks to Allen Cecil for the suggested "fix". 
  72. # define declare(a,t)        a##declare(t)
  73. # define implement(a,t)      a##implement(t)
  74. # define declare2(a,t1,t2)   a##declare2(t1,t2)
  75. # define implement2(a,t1,t2) a##implement2(t1,t2)
  76. #else /* applec */
  77. #define declare(a,t) name2(a,declare)(t)
  78. #define implement(a,t) name2(a,implement)(t)
  79. #define declare2(a,t1,t2) name2(a,declare2)(t1,t2)
  80. #define implement2(a,t1,t2) name2(a,implement2)(t1,t2)
  81.  
  82. #endif
  83.  
  84. extern genericerror(int, char*);
  85. typedef int (*GPT)(int, char*);
  86. #define set_handler(generic,type,x) name4(set_,type,generic,_handler)(x)
  87. #define errorhandler(generic,type) name3(type,generic,handler)
  88. #define callerror(generic,type,a,b) (*errorhandler(generic,type))(a,b)
  89.  
  90. #endif
  91.